public class Account {

    private Long money = 0L;
    private final String accNumber;
    private Boolean locked = false;

    public Account(String accNumber) {
        this.accNumber = accNumber;
    }

    public long getMoney() {
        synchronized (this) {
            return money;
        }
    }

    public boolean setMoney(long money) {
        synchronized (this) {
            if (money >= 0) {
                this.money = money;
                return true;
            }
        }
        return false;
    }

    public boolean addMoney(long delta) {
        synchronized (this) {
            if (money + delta >= 0) {
                this.money += delta;
                return true;
            }
        }
        return false;
    }

    public String getAccNumber() {
        return accNumber;
    }

    public boolean isLocked() {
        synchronized (this) {
            return locked;
        }
    }

    public void setLocked(boolean locked) {
        synchronized (this) {
            this.locked = locked;
        }
    }
}
